#include<bits/stdc++.h>
using namespace std;
int T;
struct Car {
    int d,v,a;
};
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>T;
    while(T--){
        int fes = 0;//faster & a==0
        int p = 0;
        int camera[100005];
        int n,m,L,V;
        cin>>n>>m>>L>>V;
        Car cm[100005];
        for(int i = 1;i<=n;i++){
            cin>>cm[i].d>>cm[i].v>>cm[i].a;
        }
        for(int i = 1;i<=m;i++){
            cin>>camera[i];
        }
        for(int i = 1;i<=n;i++){
            if(cm[i].v>V&&cm[i].a==0){
                bool isf = 0;
                for(int j = m;camera[j]>=cm[i].d;j--){
                    isf=1;
                }
                if(!isf)continue;
                fes=max(fes,cm[i].d);
                p++;
            }
            else if(cm[i].v>V||cm[i].a>0){
                if(cm[i].v>V&&cm[i].a>0){//1
                    int firstc = -1;
                    for(int j = 1;j<=m;j++){
                        if(camera[j]>=cm[i].d){
                            firstc=j;
                            break;
                        }
                    }

                    if(firstc==-1)continue;
                    else{
                            p++;
                            fes=max(fes,cm[i].d);
                        continue;
                    }
                }



                else if(cm[i].v<=V&&cm[i].a>0){//2
                    double t = (double)(V-cm[i].v)/(double)cm[i].a;
                    double s = (double)cm[i].d + (double)cm[i].v*t+(double)(cm[i].a*t*t)/2;
                    if(s<=L){
                        int firstc = -1;
                        for(int j = 1;j<=m;j++){
                            if(camera[j]>s){
                                firstc=j;
                                break;
                            }
                        }

                        if(firstc==-1)continue;
                        else{
                                p++;
                            continue;
                        }
                    }

                }



                else if(cm[i].v>V&&cm[i].a<0){//3
                    double t = (double)(V-cm[i].v)/(double)cm[i].a;
                    double s = (double)cm[i].d + (double)cm[i].v*t+(double)(cm[i].a*t*t)/2;
                    int lastc = m+10,firstc=-1;
                    for(int j = m;camera[j]>=cm[i].d;j--){
                        if(camera[j]<s){
                            lastc=j;
                            break;
                        }
                    }
                    if(lastc==m+10)continue;
                    for(int j = 1;j<=m;j++){
                        if(camera[j]>=cm[i].d){
                            firstc=j;
                            break;
                        }
                    }
                    if(firstc==-1)continue;

                    p++;
                    continue;
                }


            }




        }


        //for(int i = 0;i<p.size();i++)cout<<p[i]<<" ";
        cout<<p<<" "<<m-1<<endl;










    }
    return 0;
}
